﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;

namespace Transport.Admin
{
    public partial class QLTaiKhoanNguoiDungAdmin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_Reset_Click(object sender, EventArgs e)
        {
            try
            {
                NguoiDungControl ctrl = new NguoiDungControl();

                foreach (GridViewRow row in GridView_User.Rows)
                {
                    CheckBox cb = (CheckBox)row.FindControl("cb_Select");
                    if (cb != null && cb.Checked)
                    {
                        string id = GridView_User.Rows[row.RowIndex].Cells[2].Text;
                        ctrl.resetPassword(id);
                    }
                }

                Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
            }
            catch (Exception)
            {

            }
        }

        protected void btn_CalHash_Click(object sender, EventArgs e)
        {
            HashAlgorithm alg = new MD5CryptoServiceProvider();
            byte[] bte = alg.ComputeHash(System.Text.Encoding.UTF8.GetBytes(txt_HashPwd.Text));
            txt_HashPwd.Text = BitConverter.ToString(bte).Replace("-", "").ToLower();
        }

        protected void DetailsView_User_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
        {
            GridView_User.DataBind();
        }
    }
}